<template>
 <div class>
      <el-card class="ep-card ep-search">
        <el-row :gutter="0">
          <el-col :span="2" style="float:right">
            <el-button type="success"  @click="save">保存</el-button>
          </el-col>
        </el-row>
      </el-card>

      <el-card header="发放过桥贷款流程">
      <el-form :model="outLoanProcessForm" ref="outLoanProcessForm" label-width="140px" class="demo-outLoanProcessForm" size="mini">
        <el-row>
          <el-col :span="24">
            <el-form-item label="第三方账户信息" prop="otherAccountInfo">
              <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="outLoanProcessForm.otherAccountInfo" style="width: 80%;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="说明" prop="remark">
              <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="outLoanProcessForm.remark" style="width: 80%;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      </el-card>

      <el-card header="	收回过桥贷款流程">
      <el-form :model="inLoanProcessForm" ref="inLoanProcessForm" label-width="140px" class="demo-inLoanProcessForm" size="mini">
        <el-row>
          <el-col :span="24">
            <el-form-item label="第三方账户信息" prop="otherAccountInfo">
              <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="inLoanProcessForm.otherAccountInfo" style="width: 80%;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row>
          <el-col :span="24">
            <el-form-item label="说明" prop="remark">
              <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="inLoanProcessForm.remark" style="width: 80%;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      </el-card>


 </div>
</template>
<script>
export default {
    data(){
        return {
          outLoanProcessForm: {
            otherAccountInfo: "",
            remark: "",
          },
          inLoanProcessForm: {
            otherAccountInfo: "",
            remark: "",
          },
          projId:'',
          bridCrossCz:false,
        }
      },
      mounted() {
      },
      methods: {
        init(projId){
          this.projId=projId;
          this.$api.formPost( 'biz/projBridgeLoanProcess/selectBridgeLoanProcess',{
            projId:projId
          }).then(res => {
                if(res.retHead.code=="0000000"){
                  let bridCrossCz=false;
                    if(res.retBody.inBridgeLoanProcess){
                      this.inLoanProcessForm=res.retBody.inBridgeLoanProcess;
                       bridCrossCz=true;
                    }
                    if(res.retBody.outBridgeLoanProcess){
                      this.outLoanProcessForm=res.retBody.outBridgeLoanProcess;
                       bridCrossCz=true;
                    }
                    this.bridCrossCz=bridCrossCz;
                }else{
                    this.$message({
                        type: 'error',
                        message: res.retHead.message
                    });
                }
           });
        },
        save(){
          let outBridgeLoanProcess=this.outLoanProcessForm;
          let inBridgeLoanProcess=this.inLoanProcessForm;
          let user=JSON.parse(sessionStorage.getItem("user"));
          let params={
            outBridgeLoanProcess:outBridgeLoanProcess,
            inBridgeLoanProcess:inBridgeLoanProcess,
            projId:this.projId,
            createUserId:user.id,
            createUserName:user.realName,
          }
          if(!this.bridCrossCz){
            this.$api.post( 'biz/projBridgeLoanProcess/doSaveOutAndInBridgeLoanProcess',params).then(res => {
              if(res.retHead.code="0000000"){
                    this.$message({
                        type: 'success',
                        message: "保存成功"
                    });
                    //关闭弹框并清空数据
                    this.outLoanProcessForm = {};
                    this.inLoanProcessForm = {};
                    this.$emit("hiddenComponent");
                }else{
                    this.$message({
                        type: 'error',
                        message: res.retHead.message
                    });
                }
            });
          }else{
            //更新
            this.$api.post( 'biz/projBridgeLoanProcess/doUpdateBridgeLoanProcess',params).then(res => {
              if(res.retHead.code="0000000"){
                    this.$message({
                        type: 'success',
                        message: "更新成功"
                    });
                    //关闭弹框并清空数据
                    this.outLoanProcessForm = {};
                    this.inLoanProcessForm = {};
                    this.$emit("hiddenComponent");
                }else{
                    this.$message({
                        type: 'error',
                        message: res.retHead.message
                    });
                }
            });
          }
         
        }
    }
}
</script>